package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class VbaProject {
   int a;
   Encoding b;
   String c;
   String d;
   String e;
   String f;
   String g;
   int h;
   int i;
   int j;
   short k;
   String l;
   ArrayList m;
   Workbook n;
   zane o;
   String p;
   boolean q;
   String r;
   String s;
   byte t;
   byte[] u;
   zbuu v;
   zbuu w;
   private VbaModuleCollection x;

   public String getName() {
      return this.d;
   }

   public void setName(String value) {
      this.d = value;
   }

   VbaProject(Workbook workbook) {
      this.n = workbook;
      this.x = new VbaModuleCollection(this);
      this.a(workbook);
   }

   private void a(Workbook var1) {
      this.q = true;
      this.b = Encoding.getDefault();
      this.r = "{CB33A643-8B4C-46B8-9472-C4D12694F216}";
      this.d = "VBAProject";
      this.s = "393222000";
      this.t = 8;
      this.x.add(1, "ThisWorkbook");
      var1.getWorksheets().e = "ThisWorkbook";
      Iterator var2 = var1.getWorksheets().iterator();

      while(var2.hasNext()) {
         Worksheet var3 = (Worksheet)var2.next();
         var3.k = var3.getName();
         this.x.add(1, var3.getName());
      }

      this.d().a("&H00000001", "{3832D640-CF90-11CF-8E43-00A0C911005A};VBE;&H00000000");
   }

   VbaProject(Workbook workbook, zane VBAStorage, String macroFn) {
      this.n = workbook;
      this.x = new VbaModuleCollection(this);
      this.o = VBAStorage;
      this.p = macroFn;
      this.t = 8;
   }

   void a(boolean var1) {
      if (var1) {
         this.t = (byte)(this.t | 4);
      } else {
         this.t &= -5;
      }

   }

   boolean a() {
      return (this.t & 255 & 8) != 0;
   }

   void b(boolean var1) {
      if (var1) {
         this.t = (byte)(this.t | 8);
      } else {
         this.t &= -9;
         this.a(true);
      }

   }

   void a(VbaProject var1) {
      this.o = var1.o;
      this.p = var1.p;
      this.q = var1.q;
      if (this.q) {
         this.a = var1.a;
         this.b = var1.b;
         this.d = var1.d;
         this.e = var1.e;
         this.f = var1.f;
         this.g = var1.g;
         this.h = var1.h;
         this.i = var1.i;
         this.j = var1.j;
         this.k = var1.k;
         this.l = var1.l;
         this.m = new ArrayList();
         com.aspose.cells.b.a.a.ze.a(this.m, (Collection)var1.m);
         this.d().b(var1.d());
         this.c = var1.c;
         this.r = var1.r;
         this.t = var1.t;
         this.u = var1.u;
         if (var1.x != null) {
            this.x = new VbaModuleCollection(this);

            for(int var2 = 0; var2 < var1.getModules().getCount(); ++var2) {
               VbaModule var3 = var1.getModules().get(var2);
               VbaModule var4 = new VbaModule(this);
               var4.a(var3);
               this.getModules().a(var4);
            }
         }
      }

   }

   com.aspose.cells.b.a.d.zm a(String var1) throws Exception {
      if (this.n.b != null && this.n.b.b != null) {
         com.aspose.cells.a.f.zi var2 = this.n.b.b.b;
         com.aspose.cells.a.f.zh var3 = var2.a(var1);
         if (var3 == null) {
            return null;
         } else {
            com.aspose.cells.b.a.d.zm var4 = var2.a(var3);
            com.aspose.cells.b.a.d.zh var5 = new com.aspose.cells.b.a.d.zh();
            com.aspose.cells.a.c.zw.a(var4, var5);
            var4.a();
            return var5;
         }
      } else {
         return null;
      }
   }

   void b() throws Exception {
      if (!this.q) {
         zane var1 = this.o;
         if (var1 == null) {
            com.aspose.cells.b.a.d.zm var2 = this.a(this.p);
            zvh var3 = new zvh(var2);
            var1 = this.o = var3.a();
         }

         zbuv var4 = new zbuv(this, var1);
         var4.a();
         this.q = true;
      }
   }

   com.aspose.cells.b.a.d.zm a(zvh var1) throws Exception {
      zane var2 = this.o;
      if (this.q && var2 == null) {
         var2 = new zane();
      }

      zbux var3;
      if (var1 == null) {
         if (this.q) {
            var3 = new zbux(this, var2);
            var3.a();
            var1 = new zvh(var2);
         } else if (this.p == null) {
            var1 = new zvh(var2);
         }

         if (var1 != null) {
            com.aspose.cells.b.a.d.zh var6 = new com.aspose.cells.b.a.d.zh();
            var1.a((com.aspose.cells.b.a.d.zm)var6);
            var6.b(0L);
            return var6;
         } else {
            return null;
         }
      } else {
         if (this.q) {
            var3 = new zbux(this, var2);
            var3.a();
         } else if (this.p != null) {
            com.aspose.cells.b.a.d.zm var5 = this.a(this.p);
            if (var5 != null) {
               zvh var4 = new zvh(var5);
               var2 = var4.a();
               this.n.getWorksheets().b(true);
            }
         }

         if (var2 != null) {
            var1.a().b("_VBA_PROJECT_CUR", var2);
         }

         return null;
      }
   }

   zbuu c() {
      if (this.v == null) {
         this.v = new zbuu();
      }

      return this.v;
   }

   zbuu d() {
      if (this.w == null) {
         this.w = new zbuu();
      }

      return this.w;
   }

   public VbaModuleCollection getModules() {
      return this.x;
   }

   void a(String var1, String var2) {
      if (this.q) {
         VbaModule var3 = this.x.get(var1);
         VbaModule var4 = this.x.get(var2);
         if (var4 != null) {
            var4.a(var3);
         } else {
            var4 = new VbaModule(this);
            var4.a(var3);
            var4.a = var2;
            var4.c = var2;
            this.x.a(var4);
         }
      }
   }
}
